package edu.kpi.pzks2.queue;

import java.util.Comparator;
import java.util.List;

import edu.kpi.pzks2.graph.Edge;
import edu.kpi.pzks2.graph.Node;
import edu.kpi.pzks2.simulator.core.QueueBuilder;
import edu.uci.ics.jung.graph.Graph;

public class QueueBuilder1 extends BaseQueueBuilder implements QueueBuilder {

    public static final String NAME = "QUEUE1";
    
    public List<Node> buildQueue(Graph<Node, Edge> graph) {
        return super.buildQueue(graph, new Comparator<NodeStatistDescriptor>() {
                public int compare(NodeStatistDescriptor o1, NodeStatistDescriptor o2) {
                    // code smells...
                    if (o1.getNormalizedSum() == o2.getNormalizedSum()) {
                        return 0;
                    }
                    
                    if (o2.getNormalizedSum() - o1.getNormalizedSum() > 0) {
                        return 1;
                    } else {
                        return -1;
                    }
                }
            });
    }

}
